<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String contextPath = request.getContextPath(); 
    request.setAttribute("contextPath", contextPath);%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>web公告管理</title>

    <!-- Bootstrap Core CSS -->
    <link href="${contextPath }/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${contextPath }/css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${contextPath }/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${contextPath }/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!--common Css-->

    <link href="${contextPath }/css/common.css" rel="stylesheet">
    <!--  <link href="${contextPath }/css/webmsg.css" rel="stylesheet">-->
    <link href="${contextPath}/iconfont/iconfont.css" rel="stylesheet">
</head>

<body>

    <div id="wrapper">

        <!-- 固定提示框 -->
        <!--<div class="popupTip">提示<span class="glyphicon glyphicon-remove"></span></div></strong></div>-->
		
        <!-- Navigation -->
        <%@include file="nav.jsp"%>
        
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header">web公告管理</h3>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <a class="btn btn-primary" href="${contextPath }/WebManager/notice/goToInsert" role="button">新增公告</a>
                        </div>
                        <!-- /.panel-heading -->
                        <c:if test="${result.message!='无公告' }">
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>编号</th>                                     
                                        <th>公告主题</th>
                                        <th>公告标题</th>                                       
                                        <th>公告详情</th>
                                        <th>发布时间</th>                                     
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                  <c:forEach items="${result.list}" var="list">
                                    <tr>
                                        <td>${list.id}</td>                                       
                                        <td>${list.noticeTheme}</td>
                                        <td>${list.noticeTitle}</td>                                     
                                        <td>${list.noticeInfo}</td>
                                        <td>${list.noticeDate}</td>                                   
                                        <td>

                                            <a href="${contextPath }/WebManager/notice/editWebNotice/${list.id}"><i class="iconfont icon-75bianji"></i></a>
                                            <a href="javascript:void(0)" class="delete" onclick="deleteId(${list.id})"><i class="iconfont icon-shanchu"></i></a>

                                        </td>
                                    </tr>
                               
                               </c:forEach>
                                </tbody>
                            </table>
                            <nav aria-label="Page navigation" class="pull-right">
                                <ul class="pagination">
                                <c:if test="${ result.data.pageNow != 1 }">
									<li><a
										href="${contextPath}/WebManager/notice/webmsg?pageNow=${ result.data.pageNow - 1 }"
										aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
									</a></li>
								</c:if>
								<c:if test="${ result.data.pageNow == 1 }">
									<li><a href="#" aria-label="Previous"> <span
											aria-hidden="true">&laquo;</span>
									</a></li>
								</c:if>

								
								<li><input type="text"  disabled="disabled" id="turn" value="${ result.data.pageNow }/${ result.data.totalPageCount }"></li>


								<c:if
									test="${ result.data.pageNow != result.data.totalPageCount }">
									<li><a
										href="${contextPath}/WebManager/notice/webmsg?pageNow=${ result.data.pageNow + 1 }"
										aria-label="Next"> <span aria-hidden="true">&raquo;</span>
									</a></li>
								</c:if>
								<c:if
									test="${ result.data.pageNow == result.data.totalPageCount }">
									<li><a href="#" aria-label="Next"> <span
											aria-hidden="true">&raquo;</span>
									</a></li>
								</c:if>
								<li><input type="text" id="turnGo"></li>
								<li><a href="javascript:turn();">跳转</a></li>
                                </ul>
                            </nav>
                        </div>
                        </c:if>
                       	<c:if test="${result.message=='无公告' }">
                       		<div style="text-align:center;font-size:2em">
                       		<span style="line-height:400px">暂无公告,</span><a href="${contextPath }/WebManager/notice/goToInsert">请添加</a>
                       		</div>
                       	</c:if>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
            </div>
        </div>
        <!-- /#page-wrapper -->

        <div class="modal fade" tabindex="-1" role="dialog" id="modal">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">提示信息</h4>
                    </div>
                     <div id="notice"></div>
                    <div class="modal-body">
                    <p>确定删除吗?</p>
                     <input type="hidden" name="deleteId" id="deleteId" />
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="sure" onclick="comfirDelete()">确定</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="${contextPath }/js/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${contextPath }/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${contextPath }/js/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${contextPath }/js/sb-admin-2.min.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
        $(function() {
            $('[data-toggle="popover"]').popover();

           /*  //删除按钮
            $(".delete").on('click', function() {
                var str = '<p>删除账号可能导致其强制下线，但账号相关会话和统计将不受影响，确认删除?</p>';
                $("#sure").val(1);
                $(".modal-body").html(str);
                $("#modal").modal('show');
            });

            //冻结按钮
            $("button.btn-danger").on('click', function() {
                var str = '<p>确定要冻结吗?</p>';
                $("#sure").val(2);
                $(".modal-body").html(str);
                $("#modal").modal('show');
            });

            //解冻按钮
            $("button.btn-success").on('click', function() {
                var str = '<p>确定要解冻吗?</p>';
                $("#sure").val(3);
                $(".modal-body").html(str);
                $("#modal").modal('show');
            });

            //确定按钮
            $("#sure").click(function() {
                $("#modal").modal('hide');
                var value = $("#sure").val();
                //1是删除 2是冻结 3是解冻
                $.ajax({
                    url: ''
                }); 
            });*/

            //提示信息封装函数
            function notice(notice) {
                var str = '';
                str += '<div class="popupTip">';
                str += notice;
                str += '<span class="iconfont icon-quxiao"></span>';
                str += '</div>';
                str += '</strong></div>';
                //wrapper插入str
                $("#wrapper").append(str);
            }

            //取消提示框
            $("#wrapper").on('click', '.glyphicon-remove', function(){
                $(".popupTip") .hide();
            });
        })
        
        
        //点击删除按钮 
         function deleteId(a){
    	$('#deleteId').val(a);
    	$("#modal").modal('show');
	} 
        
        
        //确定删除按钮
         function comfirDelete(){
        	 var deleteId = $('#deleteId').val();
 				$.ajax({
 			 	    type: "POST",
 			 	  	url:"${contextPath}/WebManager/notice/deleteWebNotice?id="+deleteId,
 			 	    dataType:'json', 
 			 	    contentType: "application/json;charset=utf-8",
 			 	  	data:"",
 			 	    success: function(data){
 			 	    	if(data.status != 1){
 			 	    		window.location.href = "${contextPath}/WebManager/notice/webmsg?pageNow=1";
 						}else{
 							notice("删除失败!");
 						}
 			 	    }
 			 	});
        }
        
        
         function turn(){
    	    	var text = $('#turnGo').val();
    	    	var reg = /^\+?[1-9][0-9]*$/;
    	        if (!reg.test(text)) {
    	        	alert('请输入正整数');
    	            dispear();
    	            return;
    	        } 
    	        if(text-${ result.data.totalPageCount }>0){
    	        	alert('请输入合理页数');
    	            dispear();
    	            return;
    	        }
    	    	console.log(text);
    	    	window.location.href = "${contextPath}/WebManager/notice/webmsg?pageNow="+text; 	
    	    }
        
    </script>

</body>

</html>